package com.lili.queue;

import java.util.LinkedList;

/**
 * @Auther: 李 力
 * @Date: 2024/8/21
 * @Description: 单调递减队列
 * @version: 1.0
 */
public class MonotonicQueue {
    private LinkedList<Integer> queue = new LinkedList<>();

    public Integer peek() {
        return queue.peekFirst();
    }

    public void poll() {
        queue.pollFirst();
    }

    public void offer(Integer value) {
        while (!queue.isEmpty() && queue.peekLast() < value) {
            queue.pollLast();
        }
        queue.offerLast(value);
    }

}
